from enum import Enum
from typing import Callable, List, Dict

from git import Optional


class StrategyEnum(Enum):
    VRS = ("VRS", "Valley and Rise Strategy", "valley_rise_strategy")
    TRS = ("TRS", "Trend Reversal Strategy", "trend_reversal_strategy")

    def __init__(self, strategy_code: str, strategy_name: str, method_name: str):
        self.strategy_code = strategy_code
        self.strategy_name = strategy_name
        self.method_name = method_name

    @staticmethod
    def get_strategy_list() -> List[Dict[str, str]]:
        """
        获取策略枚举中的所有策略信息。
        """
        return [
            {
                "strategy_code": strategy.strategy_code,
                "strategy_name": strategy.strategy_name,
            }
            for strategy in StrategyEnum
        ]

    @staticmethod
    def get_strategies_by_codes(strategy_codes: List[str]) -> List["StrategyEnum"]:
        """
        根据策略代码获取特定的策略。
        """
        return [
            strategy
            for strategy in StrategyEnum
            if strategy.strategy_code in strategy_codes
        ]

    @staticmethod
    def get_strategy_by_code(strategy_code: str) -> Optional["StrategyEnum"]:
        """
        根据单个策略代码获取策略枚举。
        """
        for strategy in StrategyEnum:
            if strategy.strategy_code == strategy_code:
                return strategy
        return None
